using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data.SqlClient;
using System.Data;

namespace BUS
{
    public class KhachHangBUS
    {
        public KhachHangDTO[] LayDanhSachKH()
        {
            KhachHangDTO[] KH = new KhachHangDTO[100];
            try
            {
                KhachHangDAO KHDao = new KhachHangDAO();
                KH = KHDao.LayDanhSachKH();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            return KH;
        }

        public void ThemKhachHang(string TenKH, string DienThoai, string DiaChi)
        {
            try
            {
                KhachHangDAO khDAO = new KhachHangDAO();
                khDAO.ThemKhachHang(TenKH, DienThoai, DiaChi);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
                
        public void CapNhatKhachHang(KhachHangDTO kh)
        {
            try
            {
                KhachHangDAO KHDao = new KhachHangDAO();
                KHDao.CapNhatKhachHang(kh);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }
        public KhachHangDTO[] TimKiemKhachHang(int MaKH)
        {
            KhachHangDTO[] kh = new KhachHangDTO[100];
            try
            {
                KhachHangDAO KHDao = new KhachHangDAO();
                kh = KHDao.TimKiemKhachHang(MaKH);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            return kh;
        }
        public KhachHangDTO[] TimKiemNangCao(KhachHangDTO kh)
        {
            KhachHangDTO[] arr = new KhachHangDTO[100];
            try
            {
                KhachHangDAO KHDao = new KhachHangDAO();
                arr = KHDao.TimKiemNangCao(kh);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            return arr;
        }

        public int ThemKhachHang_Output(int MaKH, string TenKH, string DienThoai, string DiaChi)
        {
            try
            {
                KhachHangDAO khDAO = new KhachHangDAO();
                MaKH = khDAO.ThemKhachHang_Output(MaKH, TenKH, DienThoai, DiaChi);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return MaKH;
        }
    }
}
